package behavioralPattern.strategy.example03;

import behavioralPattern.strategy.example02.Receipt;
import behavioralPattern.strategy.example02.ReceiptBuilder;

import java.util.List;

public class Client {
    public static void main(String[] args) {

        List<Receipt> list = ReceiptBuilder.getReceiptList();

        Conetxt conetxt = new Conetxt();

        StrategyFactory.init();
        for (Receipt receipt : list) {
            ReceiptHandlerStrategy strategy = StrategyFactory.getStrategy(receipt);
            if (null == strategy){
                System.out.println("策略不存在");
                continue;
            }
            conetxt.setReceiptHandlerStrategy(strategy);
            conetxt.handlerReceipt(receipt);
        }
    }
}
